#coding=utf-8
import requests,json,re
##get
#r = requests.get("http://httpbin.org/get")
#r = requests.get("http://c.itcast.cn")
#print 'text:',r.text
#print 'content:',r.content
#fp = open('dest/itcastcpp.html','w')

##get with params
#myparams={'q':'linux'}
#r =requests.get('https://www.so.com/s',myparams)
##print r.content #内容太多放入文件
#print r.url
#fp =open('dest/linux.html','w')

#fp.write(r.content)
#fp.close()


##post
#mydata={'wd':'linux','name':'xwp'}
#r = requests.post('http://httpbin.org/post',mydata)
#print r.text


##post json
#mydata={'wd':'linux','name':'xwp'}
#r = requests.post('http://httpbin.org/post',data = json.dumps(mydata))
#print r.text


##post files
myfile = {'file':open('image/face.jpg','rb')}
r = requests.post('http://httpbin.org/post',files=myfile)
print r.text
